/* Copyright 2009 Sony Mathew, Minneapolis MN. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at  http://www.apache.org/licenses/LICENSE-2.0  Unless required by applicable law or agreed to in writing, software  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */
package com.xsm.gwt.widgets.client;

import com.google.gwt.core.client.GWT;

/**
 * @author Sony Mathew
 */
public class BrowserType {
	public static enum UserAgent {
		UNKNOWN,
		GECKO,
		GECKO1_8,
		IE6,
		IE8,
		OPERA,
		SAFARI
	}
	
	// Use this method to get the browser type
	// that is setup in the gwt.xml file.
	public static BrowserType getBrowserType() {
		return GWT.create(BrowserType.class);
	}
	
	public UserAgent getUserAgent() {
		return UserAgent.UNKNOWN;
	}
	
	public boolean isGecko() {
		return getUserAgent() == UserAgent.GECKO;
	}
	
	public boolean isGecko1_8() {
		return getUserAgent() == UserAgent.GECKO1_8;
	}
	
	public boolean isIE() {
		return isIE6() || isIE8();
	}
	
	public boolean isIE6() {
		return getUserAgent() == UserAgent.IE6;
	}
	
	public boolean isIE8() {
		return getUserAgent() == UserAgent.IE8;
	}
	
	public boolean isOpera() {
		return getUserAgent() == UserAgent.OPERA;
	}
	
	public boolean isSafari() {
		return getUserAgent() == UserAgent.SAFARI;
	}
    
    public String toString() {
        return getUserAgent().toString();
    }
}
